package com.yeyks.controller.admin;

import com.yeyks.account.dal.domain.AccountInfo;
import com.yeyks.common.appcommon.dto.account.AppAccountDTO;
import com.yeyks.common.appcommon.dto.account.AppIndexDTO;
import com.yeyks.common.appcommon.param.QueryStatFeeParam;
import com.yeyks.common.appcommon.result.CommonResult;
import com.yeyks.common.utils.apputil.bean.MyBeanUtils;
import com.yeyks.commonReference.service.order.OrderHeadService;
import com.yeyks.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author Administrator
 */
@Api(tags = "AppStatisticsController_统计分析接口", description = "统计分析相关接口[]")
@RestController
@RequestMapping("/admin/statistics")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AppStatisticsController extends BaseController {

    private final OrderHeadService orderHeadService;

    /**
     * 时时获取相关统计数据(包含总金额)
     */

    @ApiOperation("获取柱形图信息")
    @PostMapping("/get/stat")
    public CommonResult<List<AppIndexDTO>> getStatFee(@Valid QueryStatFeeParam queryStatFeeParam){

        AppAccountDTO appAccountDTO = validToken(queryStatFeeParam.getToken(),
                queryStatFeeParam.getVersion(), queryStatFeeParam.getPlatform());

        return orderHeadService.getStatisticsData(queryStatFeeParam, MyBeanUtils.convert(appAccountDTO, AccountInfo.class));
        //return appMainService.getStatisticsData(queryStatFeeParam);
    }


}
